import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/match/pay_result/pay_result_controller.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

/// 支付结果
class PayResultPage extends StatelessWidget {
  const PayResultPage({super.key, required this.orderNo, required this.venueFees, required this.payType, required this.desc, required this.payResult});

  final String orderNo;
  final String payResult;
  final String payType;
  final String venueFees;
  final String desc;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xffF8FAF9),
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: const Color(0xffF8FAF9),
        elevation: 0,
        title: Text(
          '充值/缴费',
          style: TextStyle(fontSize: 16.sp, color: const Color(0xff333333)),
        ),
        iconTheme: const IconThemeData(
          color: Color(0xff333333)
        ),
      ),
      body: GetBuilder<PayResultController>(
        init: PayResultController(orderNo: orderNo),
        builder: (payResultController) {
          return  Column(
            children: [
              SizedBox(height: 15.w,),

              Container(
                margin: EdgeInsets.symmetric(horizontal: 15.w),
                width: double.infinity,
                height: 260.w,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(8.r),
                  color: Colors.white
                ),
                // child: _payResultWidget(),
                child: payResult == '0' ? Column(
                  children: [
                    SizedBox(height: 25.w,),

                    SizedBox(
                      height: 15.w,
                      child: const SpinKitThreeBounce(color: Color.fromRGBO(18, 147, 96, 1.0)),
                    ),


                    SizedBox(height: 140.w,),

                    SizedBox(
                      child: Text('等待支付处理中', style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w500, color: const Color(0xff666666)),),
                    )
                  ],
                ) : _payResultWidget(payResultController),
              )
            ],
          ) ;
        }
      ),
    );
  }

  _payResultWidget(PayResultController payResultController) {
    return Column(
      children: [

        SizedBox(height: 40.w,),
        SizedBox(
          width: 64.w,
          height: 64.w,
          child: Image.asset(payResult == '2' ? 'assets/images/pay_error.png' : 'assets/images/pay_success.png'),
        ),
        SizedBox(height: 15.w,),

        SizedBox(
          child: Text(payResult == '2' ? '支付失败'  :'支付成功', style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w500, color: const Color(0xff302E2F)),),
        ),

        SizedBox(height: 4.w,),

        SizedBox(
          child: Text(payResult == '2' ? desc : '${venueFees}元', style: TextStyle(fontSize: 12.sp, color: const Color(0xff666666)),),
        ),

        SizedBox(height: 15.w,),

        GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
            Get.back();
          },
          child: Container(
            padding: EdgeInsets.symmetric(vertical: 11.w, horizontal: 36.w),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(24.r),
              color: const Color(0xffF5F5F5)
            ),
            child: Text('确定', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: const Color(0xff499360)),),
          ),
        )
      ],
    );
  }
}